package me.caofeng.enums;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.enums
 * @Description: 订单状态
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-29 11:56
 * @Version: V1.0
 */
public enum OrderStatus {
    UNPAID(1, "待支付"),
    PAID(2, "已支付"),
    OVERTIME(3, "超时未支付"),
    SEND(4, "已发货"),
    END(5, "交易已完成"),
    CLOSE(6, "交易已关闭"),
    FINISHED(7, "交易结束，不能退款"),
    CANCEL(8,"交易取消"),
    ALL(-1,"全部");

    private int id;
    private String message;

    OrderStatus() {
    }

    OrderStatus(int id, String message) {
        this.id = id;
        this.message = message;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static OrderStatus getStatus(int id) {
        switch (id) {
            case -1:
                return ALL;
            case 1:
                return UNPAID;
            case 2:
                return PAID;
            case 3:
                return OVERTIME;
            case 4:
                return SEND;
            case 5:
                return END;
            case 6:
                return CLOSE;
            case 7:
                return FINISHED;
            case 8:
                return CANCEL;
            default:
                return UNPAID;
        }
    }

    public static OrderStatus getStatus(String status) {
        switch (status) {
            case "WAIT_BUYER_PAY":
                return UNPAID;
            case "TRADE_CLOSED":
                return CLOSE;
            case "TRADE_SUCCESS":
                return PAID;
            case "TRADE_FINISHED":
                return FINISHED;
            default:
                return UNPAID;
        }
    }
}
